import 'package:flutter/material.dart';

/// Icon types
enum IconTypes { error, success, info, warning, none }

/// Alert animation types
enum AnimationType { fromRight, fromLeft, fromTop, fromBottom, grow, shrink }

/// Library images path
const String assetsPath = "assets/dialog/";

typedef TransitionBuilder = Widget Function(
    BuildContext context,
    Animation<double> animation,
    Animation<double> secondaryAnimation,
    Widget child);

class DialogHeader {
  final String title;
  final TextStyle? titleStyle;
  final EdgeInsets? padding;
  final Alignment? alignment;
  final BoxConstraints? constraints;
  const DialogHeader(
      {this.title = '',
      this.titleStyle = const TextStyle(fontSize: 16),
      this.alignment = Alignment.centerLeft,
      this.padding = const EdgeInsets.only(left: 10, right: 10),
      this.constraints = const BoxConstraints(
        minHeight: 40,
      )});
}

class DialogBody {
  final IconTypes iconType;
  final Widget? icon;

  final Widget content;
  final TextStyle? contentStyle;
  final bool isScorll;
  final double scorllHeight;

  final EdgeInsets padding;
  final Decoration? decoration;

  const DialogBody(
      {this.iconType = IconTypes.none,
      this.icon,
      required this.content,
      this.isScorll = true,
      this.scorllHeight = 500,
      this.contentStyle,
      this.padding = const EdgeInsets.all(10),
      this.decoration});
}

class DialogFooter {
  final bool isVisible;
  final List<Widget>? actions;
  final TextStyle? actionStyle;
  final bool onWillPopActive;

  // 关闭按钮
  final Icon? close;
  final bool hasClose;
  final Function? closeFunction;

  final EdgeInsets padding;
  final Decoration? decoration;

  const DialogFooter(
      {this.isVisible = false,
      this.actions,
      this.actionStyle,
      this.onWillPopActive = false, // 点击mask关闭
      this.close,
      this.hasClose = false,
      this.closeFunction,
      this.padding = const EdgeInsets.all(0),
      this.decoration});
}

class DialogBarrier {
  final bool barrierDismissible;
  final String? barrierLabel;
  final Color? barrierColor;

  const DialogBarrier(
      {this.barrierDismissible = true, this.barrierLabel, this.barrierColor});
}

class DialogTransition {
  final AnimationType type;
  final Duration duration;
  final TransitionBuilder? builder;

  const DialogTransition(
      {this.type = AnimationType.fromTop,
      this.duration = const Duration(milliseconds: 200),
      this.builder});
}
